import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Pay from '../views/Pay.vue'
import Login from '../views/Login.vue'
import Message from '../views/Message.vue'
import Card from '../views/Card.vue'

Vue.use(VueRouter)

const routes = [
	{
		path: '/',
		name: 'Home',
		component: Home,
		meta: {
			title: 'WOW SURPRISE 中国航天',
			islogin: false
		}
	},
	{
		path: '/pay',
		name: 'Pay',
		component: Pay,
		meta: {
			title: 'WOW SURPRISE 中国航天',
			islogin: false
		}
	},
	{
		path: '/login',
		name: 'Login',
		component: Login,
		meta: {
			title: 'WOW SURPRISE 中国航天',
			islogin: false
		}
	},
	{
		path: '/message',
		name: 'Message',
		component: Message,
		meta: {
			title: 'WOW SURPRISE 中国航天',
			islogin: false
		}
	},
	{
		path: '/card',
		name: 'Card',
		component: Card,
		meta: {
			title: 'WOW SURPRISE 中国航天',
			islogin: false
		}
	}
]

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

router.beforeEach((to, from, next) => {
	/* 路由发生变化修改页面title */
	if (to.meta.title) {
		document.title = to.meta.title
	}
	next()
})

export default router
